package listener.sessionlistener.activelisten;

import java.io.Serializable;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;

/**
 * @description Session钝化活化监听器, 被监听的类必须继承Serializable, 不然钝化时该对象会从session中剔除
 *
 * @author linshuo
 *
 */
public class Student implements HttpSessionActivationListener, Serializable {
    private static final long serialVersionUID = 1L;

    @Override
    // session钝化时触发
    public void sessionWillPassivate(HttpSessionEvent se) {
        System.out.println("我要被钝化了, 要去硬盘了");
    }

    @Override
    // session活化时触发
    public void sessionDidActivate(HttpSessionEvent se) {
        System.out.println("我被活化啦, 从硬盘会到内存了");
    }

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
